package mmi.gui.widget;

import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JSlider;
import javax.swing.JToolBar;

import mmi.gui.MainFrame;

public class ProgramBar extends JToolBar {
	private static final long serialVersionUID = -8636262260100208950L;

	MainFrame parent = null;
	JButton stateButton = null;
	ColourChooser colourChooser = null;
        JSlider colourSlider = null;

        enum state { CONTENT, BORDER };
        state s = null;

	public ProgramBar(MainFrame _parent)
	{
		this.parent = _parent;
                this.s = state.CONTENT;
		add(getStateButton());

		colourChooser = new ColourChooser(parent);
		add(colourChooser);

		setFloatable(false);
	}
	/**
	 * @return the colourChooser
	 */
	public ColourChooser getColourChooser() {
		return colourChooser;
	}
	/**
	 *
	 * @return
	 */
	private JButton getStateButton()
	{
		if(stateButton == null)
		{
			stateButton = new JButton();
			stateButton.setIcon(new ImageIcon("img/colour_content.png"));
			stateButton.setToolTipText("Content Colour");
                        //stateButton.setText("Content Colour");
			stateButton.setMargin(new Insets(0, 0, 0, 0));
			stateButton.setVerticalTextPosition(BOTTOM);
			stateButton.setHorizontalTextPosition(CENTER);

			stateButton.addActionListener(new java.awt.event.ActionListener()
			{
				/*
				 * (non-Javadoc)
				 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
				 */
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
                                    switch (s) {
                                        case CONTENT:   stateButton.setIcon(new ImageIcon("img/colour_border.png"));
                                                        stateButton.setToolTipText("Border Colour");
                                                        //stateButton.setText("Border Colour");
                                                        s = state.BORDER;
                                                        colourChooser.s = colourChooser.s.BORDER;
                                                        //colourChooser.repaint();
                                                        break;
                                        case BORDER:    stateButton.setIcon(new ImageIcon("img/colour_content.png"));
                                                        stateButton.setToolTipText("Content Colour");
                                                        //stateButton.setText("Content Colour");
                                                        s = state.CONTENT;
                                                        colourChooser.s = colourChooser.s.CONTENT;
                                                        //colourChooser.repaint();
                                                        break;
                                        default: break;
                                    }

				}
			});
		}
		return stateButton;
	}

}
